-
Notifications
You must be signed in to change notification settings - Fork 0
flask example app with PostHog basics #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🧙 Wizard CIRun the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands: Test all apps:
Test all apps in a directory:
Test an individual app:
Show more apps
Results will be posted here when complete. |
| from app.api import api_bp | ||
|
|
||
|
|
||
| @api_bp.route("/burrito/consider", methods=["POST"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what have I wrought
|
|
||
| {% block content %} | ||
| <div class="card"> | ||
| <h1>Burrito Consideration Tracker</h1> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it doesn't actually matter but if you wanted to be extra kosher these would be sentence case
daniloc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
incredible
| }), 500 | ||
| else: | ||
| # Just return error without PostHog capture | ||
| return jsonify({"error": str(e)}), 500 |
Check warning
Code scanning / CodeQL
Information exposure through an exception Medium
Stack trace information
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 10 hours ago
In general, to fix information exposure via exceptions, the server should avoid returning raw exception messages or stack traces to the client. Instead, log the detailed error on the server side (or send it to an error tracking system) and return a generic, non-sensitive error message to the client, optionally with a reference ID.
In this code, the vulnerable behavior occurs in the else branch of the except block in test_error, which currently returns {"error": str(e)}. The best minimal fix, consistent with existing functionality, is to replace this with a generic error payload that does not include str(e). Since the True branch already defines a pattern ("Operation failed" plus an error ID and friendly message), we can mirror that style: keep the 500 status code and return a generic "Operation failed" and a brief description that no PostHog capture was requested, without including the exception text.
Concretely, in basics/flask/app/api/routes.py, in the test_error function’s else block (around line 56–57), replace jsonify({"error": str(e)}) with a jsonify call that uses a static message, for example:
return jsonify({
"error": "Operation failed",
"message": "An internal error occurred and was not captured in PostHog."
}), 500No new imports or helpers are required.
-
Copy modified lines R56-R60
| @@ -53,7 +53,10 @@ | ||
| "message": f"Error captured in PostHog. Reference ID: {event_id}" | ||
| }), 500 | ||
| else: | ||
| # Just return error without PostHog capture | ||
| return jsonify({"error": str(e)}), 500 | ||
| # Just return a generic error without exposing exception details | ||
| return jsonify({ | ||
| "error": "Operation failed", | ||
| "message": "An internal error occurred and was not captured in PostHog." | ||
| }), 500 | ||
|
|
||
|
|
Wizard skill for the Python framework Flask